<extend name="Public/common"/>
<block name="othercss">

 <script type="text/javascript">
 var url_cart_num = "{:U('Cart/edit_num')}";
 var url_cart_del = "{:U('Cart/del')}";
 var url_cart_delsel = "{:U('Cart/delsel')}";
 var url_cart_clear = "{:U('Cart/clear')}";
 var url_cart_total = "{:U('Cart/total')}";
 var url_check_store_num = "{:U('Cart/check_store_num')}";
 var url_check = "{:U('Check/index')}";
   var url_add_fav = "{:U('Goods/add_fav2')}";//商品收藏地址  
</script>
<script type="text/javascript" src="{$theme_path}/js/cart.js?v=20190408_1"></script> 
</block>
<block name="header">
<div class="header">
    <div class="clearfix box">
        <!--<a class="save">保存</a>-->
        <a class="return" href="javascript:history.back(-1)"><i class="return-icon"></i></a>
        <h2>购物车</h2>
    </div>
</div>
</block>
<block name="body">

   <form name="form_mycart" id="form_mycart" method="post" >
<div class="container pt50">
<empty name="cart_list"><div style="text-align:center; margin-top:50px;">暂无商品</div></empty>
    <foreach name="cart_list" item="cart_item">
    <div class="thhh-sum1 vip2_sum form"  id="tr_cart_{$cart_item.cart_id}">
        <!--商品-->
        <div class="pro-cell on clearfix">
            <div class="button"><input type="checkbox" name="sel[]" value="{$cart_item.cart_id}" checked="checked" class="check"/></div>
            <a class="imgs" href="{:U('Goods/index',array('id'=>$cart_item['goods_id']))}">
                <img src="__ROOT__{$cart_item.picture}"/>
            </a>
            <div class="lans clearfix">
                <div class="left">
                    <a class="title twos" href="{:U('Goods/index',array('id'=>$cart_item['goods_id']))}">{$cart_item.goods_name}<br />商品编号：{$cart_item.goods_sn} 
                        
                    </a>
                    <a class="mess" href="{:U('Goods/index',array('id'=>$cart_item['goods_id']))}">{$cart_item.spec_array}</a>
                    <div class="car-list">
                        <div class="number clearfix">
                            <i onclick="cart_jian({$cart_item.cart_id},{$cart_item.qi_sale})">-</i>
                            <input type="text" id="num_{$cart_item.cart_id}" name="num_{$cart_item.cart_id}" value="{$cart_item.num}" onblur="cart_num({$cart_item.cart_id},{$cart_item.qi_sale})" class="input"/>
                            <i onclick="cart_jia({$cart_item.cart_id})">+</i>
                        </div>
						<input type="hidden" id="old_num_{$cart_item.cart_id}" value="{$cart_item.num}"  />
                                    <input type="hidden" id="price_{$cart_item.cart_id}" value="{$cart_item.price}"  />
                                    <input type="hidden" id="store_num_{$cart_item.cart_id}" value="{$cart_item.store_num}" />
					
                    </div>
                </div>
                <a class="right" href="{:U('Goods/index',array('id'=>$cart_item['goods_id']))}">
                    <div class="price">¥ {$cart_item.price}</div>
                </a>
                	<div id="store_num_msg_{$cart_item.cart_id}" style="line-height:36px; font-size:14px;">
                                    <if condition="$cart_item['store_num'] elt 0">
                                        <font color=red>无货</font>
                                        <elseif condition="$cart_item['store_num'] lt $cart_item['num']" />
                                        <font color=red>仅剩{$cart_item.store_num}</font>
                                        <elseif condition="$cart_item['store_num'] elt 5" />
                                        <font color=gray>仅剩{$cart_item.store_num}</font>
                                    </if>
                                </div>
            </div>
            <div class="close">
               <a href="javascript:void(0)" class="del" onclick="cart_del({$cart_item.cart_id})">
			   <img src="{$theme_path}/images/close.png" width="60"/></a>
            </div>
        </div>
    </div>
	</foreach>
	
</div>
</form>
<!--footer-->
<div class="footer-loc">
    <div class="js-btn">
        <div class="j1 on"><img src="{$theme_path}/images/yuan-off.png" width="20"/><img src="{$theme_path}/images/yuan-on.png" width="20"/>全选</div>
        <div class="j2">合计 ￥&nbsp;<span style="font-size: 18px" id="cart_total">{$cart_total|tofixed=2}</span></div>
    </div>
    <a class="new-loc1" href="javascript:void(0)" onclick="checkout()">去结算</a>
</div>



</block>
<block name="footer">
</block>
<block name="otherjs">

<script>
     $('.pro-cell .button').click(function (e) {
        // 点击加on和check
        if ($(this).parent('.pro-cell').hasClass('on')) {
            $(this).parent('.pro-cell').removeClass('on');
            $(this).find('.check').attr('checked', false);
        } else {
            $(this).parent('.pro-cell').addClass('on');
            $(this).find('.check').attr('checked', 'checked');
        }
        // 判断是否全选
        if($('.pro-cell .button').length==$('.pro-cell.on').length !=0){
            $('.js-btn .j1 ').addClass('on')
        }else{
            if($('.js-btn .j1 ').hasClass('on')){
                if($('.pro-cell .button').length > $('.pro-cell.on').length){
                    $('.js-btn .j1 ').removeClass('on');
                }
            }
        }
		cart_total()
    })
    // 点击全选和取消全选
    $('.js-btn .j1').click(function (e) {
        if ($(this).hasClass('on')) {
            $(this).removeClass('on');
            $('.pro-cell').removeClass('on');
            $('.pro-cell .check').attr('checked', false);
        } else {
            $(this).addClass('on');
            $('.pro-cell').addClass('on');
            $('.pro-cell .check').attr('checked', 'checked');
        }
		cart_total()
    })
</script>

</block>

